package com.datang.pet.api.coverter;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-06-09 09:26
 * @notify
 * @version 1.0
 */

import org.springframework.core.convert.converter.Converter;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverterConfig implements Converter<String, Date> {
    @Override
    public Date convert(String source) {
        Date date = null;
        if(source.equals("")||source==null){
            return null;
        }
        try {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
            date = dateFormat.parse(source);
        } catch (Exception e) {

        }
        return date;
    }
}
